package com.example.bookshop.mapper;

import com.example.bookshop.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * @auth shanyue
 * @date 2025年06月04日18:52
 */
@Mapper
public interface OrderMapper {
    @Insert("INSERT INTO orders(user_id, total_price, status, create_time) " +
            "VALUES(#{userId}, #{totalPrice}, #{status}, #{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Order order);

    @Select("SELECT * FROM orders WHERE id = #{id}")
    Order findById(int id);
}
